package com.wgz.medicalmanagement.domain.entity;

import java.io.Serializable;
import java.time.LocalDateTime;

import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.EnumType;
import jakarta.persistence.Enumerated;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.Table;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.TableName;

import lombok.Data;

/**
 * 用户实体类
 * 
 * @author medical
 * @since 2023-05-29
 */
@Data
@Entity
@Table(name = "users")
@TableName("users")
public class User implements Serializable {

    private static final long serialVersionUID = 1L;

    /**
     * 主键ID
     */
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @TableId(value = "id", type = IdType.AUTO)
    private Long id;

    /**
     * 用户名
     */
    @Column(name = "username", nullable = false, unique = true)
    @TableField("username")
    private String username;

    /**
     * 密码
     */
    @Column(name = "password", nullable = false)
    @TableField("password")
    private String password;

    /**
     * 姓名
     */
    @Column(name = "name")
    @TableField("name")
    private String name;

    /**
     * 电子邮箱
     */
    @Column(name = "email")
    @TableField("email")
    private String email;

    /**
     * 联系电话
     */
    @Column(name = "phone")
    @TableField("phone")
    private String phone;
    
    /**
     * 用户角色
     */
    @Enumerated(EnumType.STRING)
    @Column(name = "role")
    @TableField("role")
    private UserRole role;

    /**
     * 是否启用
     */
    @Column(name = "enabled")
    @TableField("enabled")
    private Boolean enabled;

    /**
     * 账户是否未过期
     */
    @Column(name = "account_non_expired")
    @TableField("account_non_expired")
    private Boolean accountNonExpired;

    /**
     * 账户是否未锁定
     */
    @Column(name = "account_non_locked")
    @TableField("account_non_locked")
    private Boolean accountNonLocked;

    /**
     * 凭证是否未过期
     */
    @Column(name = "credentials_non_expired")
    @TableField("credentials_non_expired")
    private Boolean credentialsNonExpired;

    /**
     * 创建时间
     */
    @Column(name = "created_time")
    @TableField("created_time")
    private LocalDateTime createdTime;

    /**
     * 更新时间
     */
    @Column(name = "updated_time")
    @TableField("updated_time")
    private LocalDateTime updatedTime;

    /**
     * 是否删除(0:否,1:是)
     */
    @Column(name = "deleted")
    @TableField("deleted")
    @TableLogic
    private Integer deleted;
} 